﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace WebQQ批量挂QQ软件
{
    public static class ControlCrossThreadCalls
    {
        public delegate void InvokeHandler();

        /// <summary>
        /// .net2.0线程中安全访问扩展方法-事理
        /// </summary>
        /// ControlCrossThreadCalls.SafeInvoke(this, new ControlCrossThreadCalls.InvokeHandler(delegate()
        /// {
        ///    tsStatus.Text = one.Email + " 扫描完毕...";
        /// }));
        public static void SafeInvoke(Control control, InvokeHandler handler)
        {
            if (control.InvokeRequired)
            {
                control.Invoke(handler);
            }
            else
            {
                handler();
            }
        }
    }
}
